package com.mid;

/**
 * Created by Lxk on 2019/6/2.
 */
public class Solution92 {


    public ListNode reverseBetween(ListNode head, int m, int n) {
        ListNode tempHead = new ListNode(0);
        ListNode finalRes = tempHead;
        tempHead.next = head;
        int count = 0;
        while(count!=m-1){
            tempHead = tempHead.next;
            count++;
        }
        ListNode curHead = tempHead.next;
        for(int k = m;k < n;k++){
            ListNode next = curHead.next;
            curHead.next = next.next;
            next.next = tempHead.next;
            tempHead.next = next;
        }
        return finalRes.next;
    }


    public static void main(String[] args) {
        ListNode node = new ListNode(2);
        ListNode node2 = new ListNode(5);
        node.next = node2;
        Solution92 solution92 = new Solution92();
        solution92.reverseBetween(node,1,2);
    }


}
